import { Injectable, LoggerService as NestLoggerService } from '@nestjs/common';
import { createWinstonLogger } from './winston.config';
import * as winston from 'winston';

/**
 * 自定义日志服务
 */
@Injectable()
export class LoggerService implements NestLoggerService {
  private logger: winston.Logger;

  constructor() {
    this.logger = createWinstonLogger();
  }

  /**
   * 普通日志
   */
  log(message: string, context?: string) {
    this.logger.info(message, { context });
  }

  /**
   * 错误日志
   */
  error(message: string, trace?: string, context?: string) {
    this.logger.error(message, { trace, context });
  }

  /**
   * 警告日志
   */
  warn(message: string, context?: string) {
    this.logger.warn(message, { context });
  }

  /**
   * 调试日志
   */
  debug(message: string, context?: string) {
    this.logger.debug(message, { context });
  }

  /**
   * 详细日志
   */
  verbose(message: string, context?: string) {
    this.logger.verbose(message, { context });
  }
}



